package com.bdqn.t350.servlet.echarts;

import com.alibaba.fastjson.JSON;
import com.bdqn.t350.entity.PieEntity;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/echarts/ColunmServlet")
public class ColunmServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        List<PieEntity> list = new ArrayList<PieEntity>();

        //这里把“类别名称”和“销量”作为两个属性封装在一个Product类里，每个Product类的对象都可以看作是一个类别（X轴坐标值）与销量（Y轴坐标值）的集合
        list.add(new PieEntity("衬衣", 10));
        list.add(new PieEntity("短袖", 20));
        list.add(new PieEntity("大衣", 30));


        response.getWriter().print(JSON.toJSONString(list));
    }
}
